package com.xy.mock.controller;

import com.xy.mock.entity.MyBean;
import com.xy.mock.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Api(tags = "LoginController", value = "登录接口")
@RestController
public class LoginController {

    @Autowired
    private MyBean myBean;

    @ApiOperation("登录认证")
    @GetMapping("/user")
    public Map<String, String> login(
            @RequestHeader("Api-Version")
            @ApiParam("api版本")
                    String apiVersion,
            @ApiParam("用户名和密码")
                    User user) {
        Map<String, String> map = new HashMap<>();
        map.put("test", myBean.bar());
        map.put("version", apiVersion);
        map.put("username", user.getName());
        return map;
    }
}
